package graph;

public class BookReviewEdge 
{
	private BookReviewNode firstNodeConnected;
	private BookReviewNode secondNodeConnected;
	
	public BookReviewEdge(BookReviewNode node1, BookReviewNode node2)
	{
		this.firstNodeConnected = node1;
		this.secondNodeConnected = node2;
		this.firstNodeConnected.addIncidentEdge(this);
		this.secondNodeConnected.addIncidentEdge(this);
	}
	
	public BookReviewNode getFirstNodeConnected()
	{
		return this.firstNodeConnected;
	}
	
	public BookReviewNode getSecondNodeConnected()
	{
		return this.secondNodeConnected;
	}
	
	public BookReviewNode getOppositeNodeConnected(BookReviewNode node)
	{
		if(node == this.firstNodeConnected)
		{
			return this.secondNodeConnected;
		}
		else
		{
			return this.firstNodeConnected;
		}
	}
	
	/**
	 * the function "isConnectedToNode" checks if the node passed as parameter is one
	 * of the nodes connected to this edge that called the function
	 * @param node
	 * @return
	 */
	public boolean isConnectedToNode(BookReviewNode node)
	{
		if(node == this.firstNodeConnected || node == this.secondNodeConnected)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}
